﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Pages_ChangePassword : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            txtEmail.Text = HttpContext.Current.Session["User"].ToString();
        }
        if (HttpContext.Current.Session["User"] ==null)
        {
            Response.Redirect("Login.aspx");
        }
        lblMessage.Visible = false;
    }
    protected void btXacNhan_Click(object sender, EventArgs e)
    {
        string oldpass = txtMatKhau.Text.Trim();
        string newpass = txtMatKhauMoi.Text.Trim();
        string newpassNL = txtMatKhauMoiNhapLai.Text.Trim();
        if (newpass == newpassNL)
        {
            ThanhVienBLL itv = new ThanhVienBLL();
            string result = itv.ChangePassword(txtEmail.Text.Trim(), oldpass, newpass);
            Response.Write("<script>alert('" + result + "')</script>");
        }
        else
        {
            Response.Write("<script>alert('Mật khẩu nhập lại không trùng đúng!')</script>");
        }
    }
}